<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //倒计时案例
        function countDown(time){
            var nowTime = +new Date();                  //获取当前时间的时间戳
            var inputTime = +new Date(time);            //获取未来时间的时间戳
            var times = (inputTime - nowTime) / 1000;   //获取两个时间的时间戳差值
            var d = parseInt(times / 60 / 60 / 24);     //获取天数
            d = d < 10 ? '0'+ d : d;
            var h = parseInt(times / 60 / 60 % 24);     //获取小时数
            h = h < 10 ? '0'+ h : h;
            var m = parseInt(times / 60 % 60);          //获取分钟数
            m = m < 10 ? '0'+ m : m;
            var s = parseInt(times % 60);               //获取秒数
            s = s < 10 ? '0'+ s : s;
            return '距四级英语考试还有' + d + '天'+ h + '小时' + m + '分' + s + '秒';
        }
        console.log(countDown('2022-12-10 9:00:00'));
    </script>
</head>
<body>
    
</body>
</html>